import axios from '@/utils/request';
const baseMaintenanceURL = process.env.VUE_APP_MAINTENANCE_API;
const baseDeviceURL = process.env.VUE_APP_DEVICE_API;
const baseUserURL = process.env.VUE_APP_USER_API;
//工单创建
const createOrder = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/createOrder', data);
};
//工单修改
const updateOrder = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/updateOrder', data);
};
//获取用户
const getSystemUserList = data => {
    return axios.get(baseUserURL + '/user/getSystemUserList', data);
};
//获取工程师列表
const getEngineerList = data => {
    return axios.get(baseMaintenanceURL + '/maintenance/getEngineerList');
};
//获取工单详情
const getOrderDetails = data => {
    return axios.get(baseMaintenanceURL + '/maintenance/getOrderDetails?id=' + data);
};
//派单
const dispatchOrder = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/dispatchOrder', data);
};
//取消工单
const cancelOrder = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/cancelOrder', data);
};
//删除工单
const DeleteOrder = data => {
    return axios.delete(baseMaintenanceURL + '/maintenance/deleteOrder', data);
};
//获取工单接收设置
const getOrderNotificationSetting = data => {
    return axios.get(baseMaintenanceURL + '/maintenance/getOrderNotificationSetting');
};
//更换工单接收设置
const updateOrderNotificationSetting = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/updateOrderNotificationSetting', data);
};
//接单
const receiveOrder = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/receiveOrder', data);
};
//接单
const completeOrder = data => {
    return axios.post(baseMaintenanceURL + '/maintenance/completeOrder', data);
};
//获取配件
const getAccessoriesList = data => {
    return axios.get(baseDeviceURL + '/accessories/getAccessoriesList?page=1&page_size=500');
};
const getKnowCategoryList = data => {
    return axios.get(baseMaintenanceURL + '/maintenance/getKnowCategoryList');
};

//获取设备最新的项目编号
const getDeviceLastProject = data => {
  return axios.get(baseMaintenanceURL + '/maintenance/getDeviceLastProject', {
      params: data
  });
};
//获取设备最新工单联系人
const getDeviceLastContact = data => {
  return axios.get(baseMaintenanceURL + '/maintenance/getDeviceLastContact', {
      params: data
  });
};
//获取物模型配件
const getModelAccessories = data => {
  return axios.get(baseDeviceURL + '/device/getModelAccessories', {
      params: data
  });
};
//新增知识库
const createKnow = data => {
  return axios.post(baseMaintenanceURL + '/maintenance/createKnow', data);
};

//工程师工单列表
const getOrderListByEngineer = data =>
    axios.request({
        method: 'GET',
        url: baseMaintenanceURL + '/maintenance/getOrderListByEngineer',
        params: data,
        headers: {
            'Content-Type': 'application/json',
            hideLoading: false
        }
    });
//获取设备
const getDeviceList = data =>
    axios.request({
        method: 'GET',
        url: baseDeviceURL + '/device/getDeviceList',
        params: data,
        headers: {
            'Content-Type': 'application/json',
            hideLoading: false
        }
    });
//获取工单列表;
const getOrderList = data =>
    axios.request({
        method: 'GET',
        url: baseMaintenanceURL + '/maintenance/getOrderList',
        params: data,
        headers: {
            'Content-Type': 'application/json',
            hideLoading: false
        }
    });

//获取保养计划列表
const getMaintainNoticeList = data =>
axios.request({
  method: 'GET',
  url: baseMaintenanceURL + '/maintenance/getMaintainNoticeList',
  params: data,
  headers: {
      'Content-Type': 'application/json',
      hideLoading: false
  }
});

//获取保养计划详情
const getPlanDetail = data =>
axios.request({

  method: 'GET',
  url: baseMaintenanceURL + '/maintenance/getMaintainNoticeDetail',
  params: data,
  headers: {
      'Content-Type': 'application/json',
      hideLoading: false
  }
});

const transferMaintainOrder = data => {
  return axios.put(baseMaintenanceURL + '/maintenance/transferMaintainOrder', data);
};


export {
    createOrder,
    getDeviceList,
    getOrderList,
    dispatchOrder,
    updateOrder,
    getSystemUserList,
    getEngineerList,
    getOrderDetails,
    cancelOrder,
    DeleteOrder,
    getOrderNotificationSetting,
    updateOrderNotificationSetting,
    getOrderListByEngineer,
    receiveOrder,
    getAccessoriesList,
    completeOrder,
    getKnowCategoryList,
    getDeviceLastProject,
    getMaintainNoticeList,
    getPlanDetail,
    getDeviceLastContact,
    getModelAccessories,
    createKnow,
    transferMaintainOrder
};
